/*
Copyright (C) 1997-2001 Id Software, Inc.

This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  

See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
*/
// Created on 31.10.2003 by RST.
// $Id: client_respawn_t.java,v 1.6 2004/09/10 19:02:54 salomo Exp $
using System;
using Com = Suake2.UI.qcommon.Com;
using Lib = Suake2.UI.util.Lib;
using Math3D = Suake2.UI.util.Math3D;
using QuakeFile = Suake2.UI.util.QuakeFile;
//UPGRADE_TODO: The type 'java.nio.ByteBuffer' could not be found. If it was not included in the conversion, there may be compiler issues. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1262'"
using ByteBuffer = java.nio.ByteBuffer;
namespace Suake2.UI.game
{
	
	/// <summary>Client data that stays across deathmatch respawns.</summary>
	public class client_respawn_t
	{
		/// <summary>What to set client->pers to on a respawn </summary>
		protected internal client_persistant_t coop_respawn = new client_persistant_t();
		
		/// <summary>Level.framenum the client entered the game. </summary>
		protected internal int enterframe;
		
		/// <summary>frags, etc. </summary>
		protected internal int score;
		
		/// <summary>angles sent over in the last command. </summary>
		protected internal float[] cmd_angles = new float[]{0, 0, 0};
		
		/// <summary>client is a spectator. </summary>
		protected internal bool spectator;
		
		
		/// <summary>Copies the client respawn data. </summary>
		public virtual void  set_Renamed(client_respawn_t from)
		{
			coop_respawn.set_Renamed(from.coop_respawn);
			enterframe = from.enterframe;
			score = from.score;
			Math3D.VectorCopy(from.cmd_angles, cmd_angles);
			spectator = from.spectator;
		}
		
		/// <summary>Clears the client reaspawn informations. </summary>
		public virtual void  clear()
		{
			coop_respawn = new client_persistant_t();
			enterframe = 0;
			score = 0;
			Math3D.VectorClear(cmd_angles);
			spectator = false;
		}
		
		/// <summary>Reads a client_respawn from a file. </summary>
		public virtual void  read(QuakeFile f)
		{
			coop_respawn.read(f);
			System.IO.BinaryReader temp_BinaryReader;
			temp_BinaryReader = new System.IO.BinaryReader(f);
			temp_BinaryReader.BaseStream.Position = f.Position;
			enterframe = temp_BinaryReader.ReadInt32();
			System.IO.BinaryReader temp_BinaryReader2;
			temp_BinaryReader2 = new System.IO.BinaryReader(f);
			temp_BinaryReader2.BaseStream.Position = f.Position;
			score = temp_BinaryReader2.ReadInt32();
			System.IO.BinaryReader temp_BinaryReader3;
			temp_BinaryReader3 = new System.IO.BinaryReader(f);
			temp_BinaryReader3.BaseStream.Position = f.Position;
			cmd_angles[0] = temp_BinaryReader3.ReadSingle();
			System.IO.BinaryReader temp_BinaryReader4;
			temp_BinaryReader4 = new System.IO.BinaryReader(f);
			temp_BinaryReader4.BaseStream.Position = f.Position;
			cmd_angles[1] = temp_BinaryReader4.ReadSingle();
			System.IO.BinaryReader temp_BinaryReader5;
			temp_BinaryReader5 = new System.IO.BinaryReader(f);
			temp_BinaryReader5.BaseStream.Position = f.Position;
			cmd_angles[2] = temp_BinaryReader5.ReadSingle();
			System.IO.BinaryReader temp_BinaryReader6;
			temp_BinaryReader6 = new System.IO.BinaryReader(f);
			temp_BinaryReader6.BaseStream.Position = f.Position;
			spectator = temp_BinaryReader6.ReadInt32() != 0;
		}
		
		/// <summary>Writes a client_respawn to a file. </summary>
		public virtual void  write(QuakeFile f)
		{
			coop_respawn.write(f);
			System.IO.BinaryWriter temp_BinaryWriter;
			temp_BinaryWriter = new System.IO.BinaryWriter(f);
			temp_BinaryWriter.Write((System.Int32) enterframe);
			System.IO.BinaryWriter temp_BinaryWriter2;
			temp_BinaryWriter2 = new System.IO.BinaryWriter(f);
			temp_BinaryWriter2.Write((System.Int32) score);
			System.IO.BinaryWriter temp_BinaryWriter3;
			temp_BinaryWriter3 = new System.IO.BinaryWriter(f);
			temp_BinaryWriter3.Write((System.Single) cmd_angles[0]);
			System.IO.BinaryWriter temp_BinaryWriter4;
			temp_BinaryWriter4 = new System.IO.BinaryWriter(f);
			temp_BinaryWriter4.Write((System.Single) cmd_angles[1]);
			System.IO.BinaryWriter temp_BinaryWriter5;
			temp_BinaryWriter5 = new System.IO.BinaryWriter(f);
			temp_BinaryWriter5.Write((System.Single) cmd_angles[2]);
			System.IO.BinaryWriter temp_BinaryWriter6;
			temp_BinaryWriter6 = new System.IO.BinaryWriter(f);
			temp_BinaryWriter6.Write((System.Int32) (spectator?1:0));
		}
	}
}